package com.newcoin.chat;

import com.newcoin.chat.beans.entity.FriendMsgEntity;
import com.newcoin.chat.beans.entity.GroupMsgEntity;
import com.newcoin.chat.beans.ComparatorTime;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class aa {
    public static void main(String[] args) {
//        for (int i=0;i<10000;i++){
//            System.out.println((System.currentTimeMillis() / 1000L) * (int) (Math.random() * 9 + 1));
//        }
//
//        QRCodeUtil.generateQRCodeImage("2", 350, 350);

        FriendMsgEntity friendMsgEntity=new FriendMsgEntity();
        friendMsgEntity.setId(1L);
        friendMsgEntity.setCreateTimestamp(10000L);
        FriendMsgEntity friendMsgEntity1=new FriendMsgEntity();
        friendMsgEntity1.setId(2L);
        friendMsgEntity1.setCreateTimestamp(20000L);
        GroupMsgEntity groupMsgEntity=new GroupMsgEntity();
        groupMsgEntity.setId(3L);
        groupMsgEntity.setCreateTimestamp(10005L);
        GroupMsgEntity groupMsgEntity1=new GroupMsgEntity();
        groupMsgEntity1.setId(4L);
        groupMsgEntity1.setCreateTimestamp(30005L);
        List<FriendMsgEntity> lista=new ArrayList<>();
        lista.add(friendMsgEntity);
        lista.add(friendMsgEntity1);
        List<GroupMsgEntity> listb=new ArrayList<>();
        listb.add(groupMsgEntity);
        listb.add(groupMsgEntity1);
        List list=new ArrayList();
        Iterator it1=lista.iterator();
        while (it1.hasNext()){
            list.add(it1.next());
        }
        Iterator it2=listb.iterator();
        while (it2.hasNext()){
            list.add(it2.next());
        }

        ComparatorTime comparatorTime=new ComparatorTime();
        Collections.sort(list,comparatorTime);//正序排序
        Collections.reverse(list);//反转顺序（倒序）
        list.forEach(l->{
            System.out.println(l);
        });
    }
}
